package com.example.jasonrpc.server.simple;

import java.lang.reflect.Method;
import java.util.Objects;

/**
 * 表示一个具体的服务
 */
public class ServiceInstance {
    private Object target;
    private Method method;

    public ServiceInstance(Object target, Method method) {
        this.target = target;
        this.method = method;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ServiceInstance that = (ServiceInstance) o;
        return target.equals(that.target) && method.equals(that.method);
    }

    @Override
    public int hashCode() {
        return Objects.hash(target, method);
    }

    public Object getTarget() {
        return target;
    }

    public void setTarget(Object target) {
        this.target = target;
    }

    public Method getMethod() {
        return method;
    }

    public void setMethod(Method method) {
        this.method = method;
    }
}
